@extends('layout.master')

@section('title','修改积分商品')

@section('css')
    @parent
    <link href="{{ asset('plugins/bower_components/summernote/dist/summernote.css') }}" rel="stylesheet"/>
    <!-- animation CSS -->
    <link href="{{ asset('css/animate.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/icheck/skins/all.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.css') }}" rel="stylesheet">
@endsection
@section('main')

    @if (session('message'))
        <div>
            <input type="hidden" id="hidden" name="hidden" value="hidden">
            <input type="hidden" id="message" name="message" value="{{ session('message') }}">
            <input type="hidden" id="status" name="status" value="{{ session('status') }}">
        </div>
    @endif

    <div class="row">

        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <form class="form-horizontal form-material" id="publish" method="post" enctype="multipart/form-data">
                    {{--<input type="hidden" name="id" value="{{ $integralCommodity->id }}">--}}
                    <div class="row">
                        <div class="col-md-12 col-sm-8">
                            <div class="row">
                                <div class="col-md-4 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">商品名称</label>
                                        <div class="col-md-12">
                                            <input type="text" name="title" value="{{ $integralCommodity->title }}"
                                                   class="form-control form-control-line" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">花费数量</label>
                                        <div class="col-md-12">
                                            <input type="text" name="cost_coin_number"
                                                   value="{{ $integralCommodity->cost_coin_number }}"
                                                   class="form-control form-control-line" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">得到数量</label>
                                        <div class="col-md-12">
                                            <input type="text" name="recharge_amount"
                                                   value="{{ $integralCommodity->recharge_amount }}"
                                                   class="form-control form-control-line" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6 col-md-2">
                                    <label class="control-label">类型</label>
                                    <div class="example">
                                        <select style="height: 38px" name="reflect_type">
                                            @foreach (App\IntegralCommodity::$ReflectTypeDisplay as $key => $value)
                                                <option value="{{ $key }}"
                                                        @if($integralCommodity->reflect_type === $key) selected @endif >{{ $value }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group">
                                        <label class="col-md-12">展示图</label>
                                        <div class="col-md-12">
                                            <div class="form-group ">
                                                <input type="file" class="dropify"
                                                       name="photo_url"
                                                       data-default-file="{{ $integralCommodity->photo_url }}"
                                                       data-height="200px"/>
                                            </div>
                                        </div>
                                    </div>
                                    </div>
                                <div class="row">
                                    @for($i = 0; $i < 9; $i++)
                                        <div class="form-group">
                                            <label class="col-md-12">详情图{{ $i+1 }}</label>
                                            <a class="fcbtn btn-success btn-outline btn-1e waves-effect" onclick="picDel({{ $i+1 }})">删除此图</a>
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <input type="file" class="dropify infos"
                                                           id="infos{{ $i+1 }}"
                                                           @if(!empty($infos[$i]))
                                                           data-default-file="{{ $infos[$i] }}"
                                                           @endif
                                                           data-height="200px"/>
                                                    <input type="hidden" name="infos{{ $i+1 }}" id="info{{ $i+1 }}"
                                                           @if(!empty($infos[$i]))value="{{ $infos[$i] }}"@endif>
                                                </div>
                                            </div>
                                        </div>
                                    @endfor
                                </div>
                            </div>


                            <div class="form-group">
                                <a class="fcbtn btn btn-success btn-outline btn-1e waves-effect"
                                   href="/integralCommodity/list">返回列表
                                </a>
                                <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect">修改商品
                                </button>
                                {!! csrf_field() !!}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

@endsection
@section('js')
    @parent
    <!-- icheck -->
    <script src="{{ asset('plugins/bower_components/icheck/icheck.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/icheck/icheck.init.js') }}"></script>
    <script src="{{ asset('js/jasny-bootstrap.js') }}"></script>
    <!-- jQuery file upload -->
    <script src="{{ asset('plugins/bower_components/dropify/dist/js/dropify.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/summernote/dist/summernote.min.js') }}"></script>
    <script>
        $(document).ready(function () {
            // Basic
            $('.dropify').dropify();
        });
    </script>
    <script src="{{ asset('plugins/bower_components/bootstrap-select/bootstrap-select.min.js') }}"
            type="text/javascript"></script>
    <!-- bt-switch -->
    <script src="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.js') }}"></script>
    <script type="text/javascript">

        jQuery(document).ready(function () {

            $('.summernote').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
                lang: 'zh-CN',
                // placeholder: '内容',
                dialogsFade: true,
            });

            $('.inline-editor').summernote({
                airMode: true
            });

        });

        $(".bt-switch input[type='checkbox'], .bt-switch input[type='radio']").bootstrapSwitch();
        var radioswitch = function () {
            var bt = function () {
                $(".radio-switch").on("switch-change", function () {
                    $(".radio-switch").bootstrapSwitch("toggleRadioState")
                }),
                    $(".radio-switch").on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck")
                    }),
                    $(".radio-switch").on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck", !1)
                    })
            };
            return {
                init: function () {
                    bt()
                }
            }
        }();
        $(document).ready(function () {
            radioswitch.init()
        });


        // $(document).ready(function () {
        //     var hidden = $('#hidden').val();
        //     if (hidden === 'hidden') {
        //         if ($('#status').val() === 1) {
        //             toastsuccess($('#message').val());
        //         } else {
        //             toasterror($('#message').val());
        //         }
        //     }
        // });

        function picDel(sid) {
            var key = 'info' + sid;
            $("#" + key).val("");
        }


        $("#infos1").change(function () {
            var file = document.getElementById("infos1").files;
            var cover = picajax(file[0]);
            $("#info1").val(cover);
        });
        $("#infos2").change(function () {
            var file = document.getElementById("infos2").files;
            var cover = picajax(file[0]);
            $("#info2").val(cover);
        });
        $("#infos3").change(function () {
            var file = document.getElementById("infos3").files;
            var cover = picajax(file[0]);
            $("#info3").val(cover);
        });
        $("#infos4").change(function () {
            var file = document.getElementById("infos4").files;
            var cover = picajax(file[0]);
            $("#info4").val(cover);
        });
        $("#infos5").change(function () {
            var file = document.getElementById("infos5").files;
            var cover = picajax(file[0]);
            $("#info5").val(cover);
        });
        $("#infos6").change(function () {
            var file = document.getElementById("infos6").files;
            var cover = picajax(file[0]);
            $("#info6").val(cover);
        });
        $("#infos7").change(function () {
            var file = document.getElementById("infos7").files;
            var cover = picajax(file[0]);
            $("#info7").val(cover);
        });
        $("#infos8").change(function () {
            var file = document.getElementById("infos8").files;
            var cover = picajax(file[0]);
            $("#info8").val(cover);
        });
        $("#infos9").change(function () {
            var file = document.getElementById("infos9").files;
            var cover = picajax(file[0]);
            $("#info9").val(cover);
        });
    </script>
@endsection